package container

import (
	"github.com/sirupsen/logrus"
	"os"
	"path"
)

var DefaultLogFileName = "container.log"

func CreateStdOutLogFile(c *Container) *os.File {
	fullDirPath := path.Join(YcontainerRoot, "containers", c.Name)

	if _, err := os.Stat(fullDirPath); err != nil {
		os.MkdirAll(fullDirPath, 0666)
	}

	fileName := path.Join(fullDirPath, DefaultLogFileName)
	file, err := os.Create(fileName)
	if err != nil {
		logrus.Errorf("create file [%s] err: %v", fileName, err)
	}
	return file
}
